package cn.iocoder.yudao.module.ai.dal.mysql.dataset;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ai.dal.dataobject.dataset.DatasetDO;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ai.controller.admin.dataset.vo.*;

/**
 * 数据集管理 Mapper
 *
 * @author 侯俊青
 */
@Mapper
public interface DatasetMapper extends BaseMapperX<DatasetDO> {

    default PageResult<DatasetDO> selectPage(DatasetPageReqVO reqVO) {
        List<String> arr = StringUtils.isNotBlank(reqVO.getQualityStatus())? Arrays.asList(reqVO.getQualityStatus().split(",")):new ArrayList<>();
        return selectPage(reqVO, new LambdaQueryWrapperX<DatasetDO>()
                .likeIfPresent(DatasetDO::getName, reqVO.getName())
                .eqIfPresent(DatasetDO::getDescription, reqVO.getDescription())
                .eqIfPresent(DatasetDO::getSourceType, reqVO.getSourceType())
                .eqIfPresent(DatasetDO::getFileType, reqVO.getFileType())
                .eqIfPresent(DatasetDO::getOwnerOrg, reqVO.getOwnerOrg())
                .likeIfPresent(DatasetDO::getOwnerOrgName, reqVO.getOwnerOrgName())
                .eqIfPresent(DatasetDO::getSenceType, reqVO.getSenceType())
                .likeIfPresent(DatasetDO::getFileOriginalName, reqVO.getFileOriginalName())
                .eqIfPresent(DatasetDO::getFileUploadPath, reqVO.getFileUploadPath())
                .eqIfPresent(DatasetDO::getIndustryId, reqVO.getIndustryId())
                .eqIfPresent(DatasetDO::getIndustryId2, reqVO.getIndustryId2())
                .eqIfPresent(DatasetDO::getIndustryId3, reqVO.getIndustryId3())
                .eqIfPresent(DatasetDO::getIndustryId, reqVO.getIndustryId())
                .eqIfPresent(DatasetDO::getLabelInfo, reqVO.getLabelInfo())
                .eqIfPresent(DatasetDO::getDuration, reqVO.getDuration())
                .eqIfPresent(DatasetDO::getContainFileNum, reqVO.getContainFileNum())
                .eqIfPresent(DatasetDO::getMarkFileNum, reqVO.getMarkFileNum())
                .eqIfPresent(DatasetDO::getMarkFileClasses, reqVO.getMarkFileClasses())
                .eqIfPresent(DatasetDO::getFileSize, reqVO.getFileSize())
                .inIfPresent(DatasetDO::getQualityStatus, arr)
                .eqIfPresent(DatasetDO::getQualityUserId, reqVO.getQualityUserId())
                .betweenIfPresent(DatasetDO::getQualityTime, reqVO.getQualityTime())
                .eqIfPresent(DatasetDO::getPublishStatus, reqVO.getPublishStatus())
                .betweenIfPresent(DatasetDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(DatasetDO::getCreateTime, reqVO.getCreateTimeBegin(),reqVO.getCreateTimeEnd())
                .eqIfPresent(DatasetDO::getSuplierId, reqVO.getSuplierId())
                .eqIfPresent(DatasetDO::getMarkStatus, reqVO.getMarkStatus())
                .likeIfPresent(DatasetDO::getQualityTaskName, reqVO.getQualityTaskName())
                .eqIfPresent(DatasetDO::getQualityTaskDescription, reqVO.getQualityTaskDescription())
                .betweenIfPresent(DatasetDO::getQualityTaskCreateTime, reqVO.getQualityTaskCreateTime())
                .eqIfPresent(DatasetDO::getQualityTaskUserId, reqVO.getQualityTaskUserId())
                .eqIfPresent(DatasetDO::getQualityTaskFlag, reqVO.getQualityTaskFlag())
                .orderByDesc(DatasetDO::getId));
    }


}